<?php

namespace App\Models\Payment;

use App\Traits\UuidTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasOne;

class PaymentScene extends Model
{
    use UuidTrait;

    const TABLE = 'payment_scenes';
    protected $table = self::TABLE;

    const SOURCE_APP = 'APP';
    const SOURCE_MWEB = 'MWEB';
    const SOURCE_MINI = 'MINI';

    const SCENE_TMP_PAYMENT = '临停缴费';
    const SCENE_MONTHLY_PAYMENT = '月租缴费';
    const SCENE_MERCHANT_PAYMENT = '商户充值';
    const SCENE_COUPON_PAYMENT = '购买优惠券';
    const SCENE_MERCHANT_TMP_PAYMENT = '临停代付';

    const SCENES = [
        self::SCENE_TMP_PAYMENT,
        self::SCENE_MONTHLY_PAYMENT,
        self::SCENE_MERCHANT_PAYMENT,
        self::SCENE_COUPON_PAYMENT,
        self::SCENE_MERCHANT_TMP_PAYMENT
    ];

    const SOURCES = [self::SOURCE_MINI, self::SOURCE_APP, self::SOURCE_MWEB];

    const DEFAULT = [
        self::SCENE_MONTHLY_PAYMENT => [
            self::SOURCE_MWEB => [PaymentChannel::CATEGORY_CHINAUMS, PaymentChannel::CATEGORY_UNIONPAY_WECHATPAY, PaymentChannel::CATEGORY_UNIONPAY_ALIPAY, PaymentChannel::CATEGORY_FUIOUPAY, PaymentChannel::CATEGORY_FUIOUPAY_AGGREGATE, PaymentChannel::CATEGORY_EBANKPAY],
            self::SOURCE_MINI => [PaymentChannel::CATEGORY_CHINAUMS, PaymentChannel::CATEGORY_UNIONPAY_WECHATPAY_MINI, PaymentChannel::CATEGORY_FUIOUPAY, PaymentChannel::CATEGORY_FUIOUPAY_AGGREGATE, PaymentChannel::CATEGORY_EBANKPAY]
        ],
        self::SCENE_TMP_PAYMENT => [
            self::SOURCE_MWEB => [PaymentChannel::CATEGORY_CHINAUMS, PaymentChannel::CATEGORY_UNIONPAY_WECHATPAY, PaymentChannel::CATEGORY_UNIONPAY_ALIPAY, PaymentChannel::CATEGORY_FUIOUPAY, PaymentChannel::CATEGORY_FUIOUPAY_AGGREGATE, PaymentChannel::CATEGORY_EBANKPAY],
            self::SOURCE_MINI => [PaymentChannel::CATEGORY_CHINAUMS, PaymentChannel::CATEGORY_UNIONPAY_WECHATPAY_MINI, PaymentChannel::CATEGORY_FUIOUPAY, PaymentChannel::CATEGORY_FUIOUPAY_AGGREGATE, PaymentChannel::CATEGORY_EBANKPAY]
        ],
        self::SCENE_MERCHANT_PAYMENT => [
            self::SOURCE_MWEB => [PaymentChannel::CATEGORY_CHINAUMS, PaymentChannel::CATEGORY_UNIONPAY_WECHATPAY, PaymentChannel::CATEGORY_UNIONPAY_ALIPAY, PaymentChannel::CATEGORY_FUIOUPAY, PaymentChannel::CATEGORY_FUIOUPAY_AGGREGATE, PaymentChannel::CATEGORY_EBANKPAY],
            self::SOURCE_MINI => [PaymentChannel::CATEGORY_CHINAUMS, PaymentChannel::CATEGORY_UNIONPAY_WECHATPAY_MINI, PaymentChannel::CATEGORY_FUIOUPAY, PaymentChannel::CATEGORY_FUIOUPAY_AGGREGATE, PaymentChannel::CATEGORY_EBANKPAY]
        ],
        self::SCENE_COUPON_PAYMENT => [
            self::SOURCE_MWEB => [PaymentChannel::CATEGORY_CHINAUMS, PaymentChannel::CATEGORY_UNIONPAY_WECHATPAY, PaymentChannel::CATEGORY_UNIONPAY_ALIPAY, PaymentChannel::CATEGORY_FUIOUPAY, PaymentChannel::CATEGORY_FUIOUPAY_AGGREGATE, PaymentChannel::CATEGORY_EBANKPAY],
            self::SOURCE_MINI => [PaymentChannel::CATEGORY_CHINAUMS, PaymentChannel::CATEGORY_UNIONPAY_WECHATPAY_MINI, PaymentChannel::CATEGORY_FUIOUPAY, PaymentChannel::CATEGORY_FUIOUPAY_AGGREGATE, PaymentChannel::CATEGORY_EBANKPAY]
        ],
        self::SCENE_MERCHANT_TMP_PAYMENT => [
            self::SOURCE_MWEB => [PaymentChannel::CATEGORY_CHINAUMS, PaymentChannel::CATEGORY_UNIONPAY_WECHATPAY, PaymentChannel::CATEGORY_UNIONPAY_ALIPAY, PaymentChannel::CATEGORY_FUIOUPAY, PaymentChannel::CATEGORY_FUIOUPAY_AGGREGATE, PaymentChannel::CATEGORY_EBANKPAY],
            self::SOURCE_MINI => [PaymentChannel::CATEGORY_CHINAUMS, PaymentChannel::CATEGORY_UNIONPAY_WECHATPAY_MINI, PaymentChannel::CATEGORY_FUIOUPAY, PaymentChannel::CATEGORY_FUIOUPAY_AGGREGATE, PaymentChannel::CATEGORY_EBANKPAY]
        ],
    ];

    public function paymentChannel(): HasOne
    {
        return $this->hasOne(PaymentChannel::class, 'id','channel_id');
    }
}
